<template>
  <view v-show="show" class="share-poster-mask" @touchmove.stop.prevent>
    <view class="share-poster-dialog">
      <view class="share-poster-img-box">
        <image src="/static/shara720.png" class="share-poster-img" mode="widthFix" />
        <!-- 新增：邀请码浮层，绝对定位在图片上 -->
        <view class="poster-invite-code">
          <text class="invite-label">邀请码：</text>
          <text class="invite-code">{{ inviteCode || '无' }}</text>
        </view>
      </view>
      <!-- 下面是按钮区，不变 -->
      <view class="share-poster-btns">
        <button class="share-cancel-btn" @click="onCancel">
          取消分享
        </button>
        <button class="share-confirm-btn" @click="onSharePoster">
          分享海报
        </button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "SharePoster",
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    posterImage: {
      type: String,
      default: "/static/shara720.png",
    },
    inviteCode: {
      type: String,
      default: "",
    },
  },

  methods: {
    // 分享海报按钮事件
    onSharePoster() {
      this.$emit("share")
    },
    onCancel() {
      this.$emit("cancel")
    },
  },
}
</script>

<style lang="scss" scoped>
.share-poster-mask {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-poster-dialog {
  width: 80vw;
  max-width: 600rpx;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 24rpx);
}

.share-poster-img-box {
  position: relative;
  width: 100%;

  .share-poster-img {
    width: 100%;
    display: block;
    border-radius: 24rpx 24rpx 0 0;
  }

  .poster-invite-code {
    position: absolute;
    left: 0;
    right: -2px;
    top: 94%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 28rpx;
    color: #fff;
    z-index: 2;

    .invite-label {
      color: #fff;
      font-weight: 400;
      margin-right: 8rpx;
      text-shadow: 0 2rpx 8rpx #000;
    }

    .invite-code {
      color: #fff;
      font-weight: bold;
      text-shadow: 0 2rpx 8rpx #000;
      letter-spacing: 2rpx;
    }
  }
}

.share-poster-btns {
  width: 72%;
  display: flex;
  justify-content: space-between;
  border-radius: 24rpx;
  box-sizing: border-box;
  margin-top: 20rpx;
}

.share-cancel-btn,
.share-confirm-btn {
  flex: 1;
  height: 80rpx;
  font-size: 32rpx;
  border-radius: 40rpx;
  margin: 0 20rpx;
  border: none;
  outline: none;
}

.share-cancel-btn {
  background: #e6eaf2;
  color: #3a3a44;
}

.share-confirm-btn {
  background: #4666ff;
  color: #fff;
}
</style>
